#include "musicplayer.h"

#include <QApplication>
#include <QSharedMemory>
#include <QMessageBox>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    // 创建共享内存
    QSharedMemory shareMem("MusicPlayer");
    // 如果共享内存已经被占用, 说明有实例运行
    if (shareMem.attach())
    {
        QMessageBox::information(nullptr, "MusicPlayer", "已经在运行");
        return 0;
    }

    shareMem.create(1);
    MusicPlayer w;
    w.show();
    return a.exec();
}
